package com.wiscamp.ninechapters.tags.application.assemblers;

import com.wiscamp.ninechapters.tags.application.dto.command.CreateKnowledgePointCommand;
import com.wiscamp.ninechapters.tags.application.dto.command.CreateKnowledgePointRelationCommand;
import com.wiscamp.ninechapters.tags.application.dto.command.UpdateKnowledgePointCommand;
import com.wiscamp.ninechapters.tags.application.dto.command.UpdateKnowledgePointRelationCommand;
import com.wiscamp.ninechapters.tags.application.dto.vo.KnowledgePointRelationVO;
import com.wiscamp.ninechapters.tags.application.dto.vo.KnowledgePointVO;
import com.wiscamp.ninechapters.tags.application.dto.vo.KnowledgeTreePointVO;
import com.wiscamp.ninechapters.tags.domain.models.KnowledgePoint;
import com.wiscamp.ninechapters.tags.domain.models.KnowledgePointRelation;
import com.wiscamp.ninechapters.tags.domain.models.KnowledgeTreePoint;
import jakarta.validation.constraints.NotNull;
import org.mapstruct.*;
import org.mapstruct.factory.Mappers;

@Mapper(componentModel = "spring",
        unmappedTargetPolicy = ReportingPolicy.IGNORE,
        unmappedSourcePolicy = ReportingPolicy.IGNORE,
        nullValuePropertyMappingStrategy = NullValuePropertyMappingStrategy.IGNORE,
        nullValueCheckStrategy = NullValueCheckStrategy.ALWAYS)
public interface KnowledgePointAssembler {
    KnowledgePointAssembler Instance = Mappers.getMapper(KnowledgePointAssembler.class);

    // region knowledge point
    KnowledgePointVO toKnowledgePointVO(@NotNull KnowledgePoint entity);

    KnowledgePoint fromCreateCommand(@NotNull CreateKnowledgePointCommand createCommand);

    @Mapping(source = "enabled", target = "enabled")
    KnowledgePoint fromUpdateCommand(@NotNull UpdateKnowledgePointCommand updateCommand);

    // endregion

    // region relation
    KnowledgePointRelationVO toKnowledgePointRelationVO(@NotNull KnowledgePointRelation entity);

    KnowledgePointRelation fromCreateCommand(@NotNull CreateKnowledgePointRelationCommand createCommand);

    KnowledgePointRelation fromUpdateCommand(@NotNull UpdateKnowledgePointRelationCommand updateCommand);
    // endregion

    // region knowledge tree
    KnowledgeTreePointVO toKnowledgeTreePointVO(KnowledgeTreePoint treePoint);
    // endregion
}
